<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>css-dom操作</title>
  <script type="text/javascript" src="../script/jquery-3.6.0.min.js"></script>
  <script type="text/javascript">
    $(function (){
      $("#b1").click(function (){
        var width = $("img").width();
        alert("width=" + width);
        //offset 获取元素在当前视窗中(默认左上角)的相对位移，返回了对象包含两个属性top left，只对可见元素有效
        var offset = $("img").offset();
        alert("img的 top = " + offset.top);
        alert("img的 left = " + offset.left);
      })
    })
  </script>
</head>
<body>
<br/><br/><br/>
hello,world~<img src="../image/1.png" width="200">
<button id="b1" type="button">获取图片信息</button>
</body>
</html>
